package com.le.tester.config;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * createTime：2025-04-10 16:42
 * description：员工mybatis配置
 */
@Configuration
@MapperScan(basePackages = "com.le.tester.dao", sqlSessionFactoryRef = "sqlSessionFactoryEmployee")
public class EmployeeMyBatisConfig {

    @Bean("sqlSessionFactoryEmployee")
    @Primary
    public SqlSessionFactory sqlSessionFactoryEmployee(@Qualifier("employeeDataSource") DataSource dataSource) throws Exception {
        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
        factoryBean.setDataSource(dataSource);
        return factoryBean.getObject();

    }
}
